package cn.wolfcode.wolf2w.Exception;

import cn.wolfcode.wolf2w.util.JsonResult;
import cn.wolfcode.wolf2w.util.LogicException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class HandleException {

    @ExceptionHandler(LogicException.class)
    @ResponseBody
    public Object HandleLogic(Exception e){
        e.printStackTrace();
        return new JsonResult<>(JsonResult.CODE_ERROR,e.getMessage(),null);
    }

    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public Object HandleExp(Exception e){
        e.printStackTrace();
        return JsonResult.defaultError();
    }
}
